package com.sunwhite.easycoding.lockdemo;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class castest {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        atomicInteger.incrementAndGet();
        System.out.println(atomicInteger);

    }

    public static void getObjectInfo(){
        Object o = new Object();

        System.out.println();
    }

    /**
     * StringBuffer是线城安全的，看append方法如何进行线城优化的
     */
    public static void stringBufferSafe(){
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("212");
    }


    public  static void lockTest(){
        ReentrantLock reentrantLock = new ReentrantLock();
        Condition condition = reentrantLock.newCondition();
        boolean b = reentrantLock.tryLock();
        if (b){
            reentrantLock.lock();
        }
        condition.signal();
        reentrantLock.unlock();

    }
}
